<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;

class CategoryGroup extends Model
{
    use HasFactory, PimpableTrait;

    protected $fillable = ['name', 'flag', 'user_id'];

    // 和用户的关联
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    // 和分组的关联
    public function category()
    {
        return $this->hasMany(Category::class, 'category_group_id', 'id');
    }
}
